// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import ComponentBase from "../../../../general/Script/component/ComponentBase";
import { BlockColors, ScoreType } from "../content";


const {ccclass, property} = cc._decorator;



@ccclass
export default class AddScore extends ComponentBase {

   

    score:cc.Node = null
    effect:cc.Node = null;
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {

    }



    setScoreAndLine(score:number,line:number,colorType:number){
        this.score.getComponent(cc.Label).string = score.toString();

        this.effect.getComponent(cc.Label).string = ScoreType[line.toString()]+'!';
        
       this.effect.getComponent(cc.LabelOutline).color = BlockColors[colorType]; this.effect.color = BlockColors[colorType];
        return  ScoreType[line.toString()]
    }


    runScoreAction(){
        this.node.scale = 2;
        this.score.scale = 0.01;
        this.effect.scale = 0.01;
        this.score.runAction(cc.sequence(cc.delayTime(0.05),cc.scaleTo(0.08,1)));
        this.effect.runAction(cc.scaleTo(0.2,1).easing(cc.easeBackInOut()));
        this.node.runAction(cc.sequence(cc.delayTime(0.8),cc.fadeOut(0.3),cc.callFunc(()=>{
            this.node.removeFromParent();
            this.node.destroy();
        })));


    }
    // update (dt) {}
}
